package com.mlnx.web.ui.controller;

import com.mlnx.common.entity.Response;
import com.mlnx.ui.entity.AmbulatoryBpSetting;
import com.mlnx.ui.service.AmbulatoryBpSettingService;

import org.shan.spring.base.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@Api(value = "UI血压接口", tags = {"UI血压接口"})
@RestController
@RequestMapping("ui/bp")
public class BpUiController extends BaseController {
    @Autowired
    private AmbulatoryBpSettingService ambulatoryBpSettingService;


    @ApiOperation("保存动态血压监测参数")
    @PostMapping(value = "/ambulatory/setting")
    public Response saveBpSetting(@RequestBody AmbulatoryBpSetting ambulatoryBpSetting) {
        ambulatoryBpSettingService.saveBpSetting(ambulatoryBpSetting);

        return result();
    }

    @ApiOperation("通过患者ID获取绑定的动态血压监测参数")
    @GetMapping(value = "/ambulatory/setting")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "patientId", value = "患者ID", required = true)
    })
    public Response getBoundBpSetting(@RequestParam("patientId") Integer patientId) {
        AmbulatoryBpSetting ambulatoryBpSetting = ambulatoryBpSettingService.getBoundBpSetting(patientId);

        return result(ambulatoryBpSetting);
    }
}
